// 库存查询
import React from 'react';
import { Row, Col, Input, Select, Button, DatePicker, Switch, Icon, Table, Checkbox, Card, Modal, message, Tooltip } from 'antd';
import store from '../../store';
import { handleExcel } from 'tools/handleExcel.js';
import PubilcTablePagination from '../common/PubilcTablePagination.jsx';
import CommonPagination from 'components/pagination/index';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';
import './style/index.less';
import { $http } from 'containers/config/https';
import Moment from 'moment';
import { $loadTemplate } from '../lodop/Common/Print.js';

let user = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
const { Option } = Select;

export default class StockSearch extends React.Component {
	constructor() {
		super();
		this.state = {
			total: 0,
			mainData: [],
			rowId: '', // 选中行id
			visible: false,
			checkMainValue: false,
			checkDetailValue: false,
			drugNames: undefined, // 药品名称
			selectData: {}, // 下拉框数据
			locID: user && user.locID ? user.locID : undefined, // 科室
			stockID: undefined, // 药品
			endDate: undefined, // 日期
			stkCatID: undefined, // 库存分类
			poisonID: undefined, // 管制分类
			busTypeID: undefined, // 类型
			formID: undefined, // 剂型
			onlyUse: undefined, // 仅在用药品
			onlyNotUse: undefined, // 仅不可用药品
			mainPageSize: 10,
			mainPage: 1,
			rowData: {}, // 选中行数据
			detailData: [], // 批次信息表格数据
			detailPageSize: 10,
			detailPage: 1,
			detailTotal: 0,
			transitVisible: false, // 在途数列表是否显示
			transitSelectedRowKeys: [],
			transitRowData: [],
			transitRowId: '',
			rowDataModal: {}, // 点击清除在途数，所在行数据
			transitTableData: [], // 在途数表格数据
			transitPageSize: 10,
			transitPage: 1,
			transitTotal: 0,
			transitValue: undefined, // 开单科室
			flag: '', // 在途数点击的是库存信息(main)还是批次信息(detail)
			alias: undefined,
			publicLoading: false,
			detailColumnsWidth: '',
			columns: [],
			columnsWidth: '',
			detailColumns: [],
			ChineseEnglishSize: {},
			transitColumns: [],
			parameterCode: '',
			transitColumnsWidth: '',
			printOneStatus: true,

			language: JSON.parse(window.sessionStorage.userData),
		};
		this.columns = [
			{
				title: '加锁', dataIndex: 'lockFlag', key: '16', width: '150px', align: "center",
				render: (text, record) => (
					<Switch checkedChildren="是" unCheckedChildren="否" checked={record.lockFlag} onChange={(e, event) => this.handleMainSwitch(record, e, event)}></Switch>
				)
			},
			{ title: '代码', dataIndex: 'stockCode', key: '1', width: '150px', align: "center" },
			{ title: '药品名称', dataIndex: 'stockDesc', key: '2', width: '400px', align: "center" },
			{ title: '规格', dataIndex: 'stockSpec', key: '3', width: '150px', align: "center" },
			{
				title: '在途数', dataIndex: 'resQty', key: '10', width: '150px', align: "center",
				render: (text, record) => (
					<Tooltip title="点击在途数可进行相关操纵" placement="topLeft">
						<span className="table-operation">
							<a href="javascript:;" onClick={(e) => this.handleMunuItemOne(record, 'main', e)}>
								{record.resQty}
							</a>
						</span>
					</Tooltip>
				)
			},
			{ title: '基本单位库存', dataIndex: 'locBQty', key: '6', width: '150px', align: "center" },
			{ title: '入库单位库存', dataIndex: 'locPQty', key: '8', width: '150px', align: "center" },
			{ title: '占用数', dataIndex: 'dirQty', key: '9', width: '150px', align: "center" },
			{ title: '剂型', dataIndex: 'stockForm', key: '4', width: '150px', align: "center" },
			{ title: '货位码', dataIndex: 'stkLocBin', key: '5', width: '150px', align: "center" },
			{ title: '进价', dataIndex: 'rp', key: '11', width: '100px', align: "center" },
			{ title: '进价金额', dataIndex: 'rpAmt', key: '12', width: '100px', align: "center" },
			{ title: '售价', dataIndex: 'sp', key: '13', width: '100px', align: "center" },
			{ title: '售价金额', dataIndex: 'spAmt', key: '14', width: '100px', align: "center" },
		];
		this.detailColumns = [
			{
				title: '医嘱激活', dataIndex: 'ordActive', key: '1', width: '150px', align: "center",
				render: (text, record) => (
					<Switch checkedChildren="是" unCheckedChildren="否" checked={record.ordActive === 1 ? true : false} onChange={(e) => this.handleChange(record, 'ordActive', e)}></Switch>
				)
			},
			{
				title: '库存激活', dataIndex: 'stkActive', key: '2', width: '150px', align: "center",
				render: (text, record) => (
					<Switch checkedChildren="是" unCheckedChildren="否" checked={record.stkActive === 1 ? true : false} onChange={(e) => this.handleChange(record, 'stkActive', e)}></Switch>
				)
			},
			{ title: '批号', dataIndex: 'batNo', key: '3', width: '150px', align: "center" },
			{ title: '有效期', dataIndex: 'expDate', key: '4', width: '150px', align: "center" },
			{ title: '生产日期', dataIndex: 'produceDate', key: '5', width: '150px', align: "center" },
			{ title: '库存数', dataIndex: 'batQty', key: '6', width: '150px', align: "center" },
			{
				title: '在途数', dataIndex: 'batResQty', key: '8', width: '150px', align: "center",
				render: (text, record) => (
					<Tooltip title="点击在途数可进行相关操纵" placement="topLeft">
						<span className="table-operation">
							<a href="javascript:;" onClick={(e) => this.handleMunuItemOne(record, 'detail', e)}>
								{record.batResQty}
							</a>
						</span>
					</Tooltip>
				)
			},
			{ title: '占用数', dataIndex: 'dirQty', key: '7', width: '150px', align: "center" },
			{ title: '进价(基本单位)', dataIndex: 'baseRp', key: '9', width: '150px', align: "center" },
			{ title: '售价(基本单位)', dataIndex: 'baseSp', key: '10', width: '150px', align: "center" },
			{ title: '进价(售价单位)', dataIndex: 'purRp', key: '11', width: '150px', align: "center" },
			{ title: '售价(售价单位)', dataIndex: 'purSp', key: '12', width: '150px', align: "center" },
			{ title: '生产厂家', dataIndex: 'manfDesc', key: '13', width: '200px', align: "center" },
			{ title: '供应商', dataIndex: 'vendorDesc', key: '14', width: '200px', align: "center" },
		];
		this.transitColumns = [
			{ title: '开单科室', dataIndex: 'ordLocDesc', key: '1', width: '150px', align: "center" },
			{ title: '病人ID', dataIndex: 'patNo', key: '2', width: '100px', align: "center" },
			{ title: '病人姓名', dataIndex: 'patName', key: '3', width: '100px', align: "center" },
			{ title: '数量', dataIndex: 'qty', key: '4', width: '100px', align: "center" },
			{ title: '单位', dataIndex: 'baseUnitDesc', key: '5', width: '100px', align: "center" },
			{ title: '批号', dataIndex: 'batNo', key: '6', width: '150px', align: "center" },
			{ title: '有效期', dataIndex: 'expDate', key: '7', width: '100px', align: "center" },
			{ title: '生产厂家', dataIndex: 'manfDesc', key: '8', width: '200px', align: "center" },
			{ title: '供应商', dataIndex: 'vendorDesc', key: '9', width: '200px', align: "center" },
			{ title: '日期', dataIndex: 'createDate', key: '10', width: '100px', align: "center" },
			{ title: '时间', dataIndex: 'createTime', key: '11', width: '100px', align: "center" },
		]
		this.myRef1 = React.createRef();
		this.myRef2 = React.createRef();
		this.myRef3 = React.createRef();
		this.myRef4 = React.createRef();
		this.myRef5 = React.createRef();
		this.myRef6 = React.createRef();
		this.myRef7 = React.createRef();
		this.myRef8 = React.createRef();
		this.myRef9 = React.createRef();
	}

	componentDidMount() {
		this.handleQuery();
		this.getSelectData();
		this.getTransitSelectData();
		this.getColumnsTable1();
		this.getColumnsTable2();
		this.getColumnsTable3();
	}

	// 获取明系列表头数据
	getColumnsTable1 = () => {
		let { language } = this.state;
		let data = {
			params: [{
				reactCode: ['InventoryInfo'],
				compontName: 'InventoryInfo',
				type: 'C',
			}]
		}
		$http.post('urlS', this, {
			code: '01040073',
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					let arr = res.result.C && res.result.C.length > 0 ? JSON.parse(JSON.stringify(res.result.C)).map((item, index) => {
						return {
							...item,
							key: index + 1,
							title: <div onDoubleClick={() => {
								this.setState({ parameterCode: 'InventoryInfo' }, () => {
									this.columnRef.onOpenModel();
								})
							}}>{language.language == 'EN' ? item.enDescripts : item.title}</div>,
							render: (text, record) => {
								if (item.code === 'lockFlag') {
									return <Switch checkedChildren={language.language == 'EN' ? 'YES' : "是"} unCheckedChildren={language.language == 'EN' ? 'NO' : "否"} checked={record.lockFlag} onChange={(e, event) => this.handleMainSwitch(record, e, event, 'lockFlag')}></Switch>
								} else if (item.code === 'resQty') {
									return <Tooltip title={language.language == 'EN' ? 'Click on the number of paths to perform related operations' : "点击在途数可进行相关操纵"} placement="topLeft">
										<span className="table-operation">
											<a href="javascript:;" onClick={(e) => this.handleMunuItemOne(record, 'main', e)}>
												{record.resQty}
											</a>
										</span>
									</Tooltip>
								} else if (item.code === 'outLockFlag') {
									return <Switch checkedChildren={language.language == 'EN' ? 'YES' : "是"} unCheckedChildren={language.language == 'EN' ? 'NO' : "否"} checked={record.outLockFlag} onChange={(e, event) => this.handleMainSwitch(record, e, event, 'outLockFlag')}></Switch>
								} else if (item.code === 'inLockFlag') {
									return <Switch checkedChildren={language.language == 'EN' ? 'YES' : "是"} unCheckedChildren={language.language == 'EN' ? 'NO' : "否"} checked={record.inLockFlag} onChange={(e, event) => this.handleMainSwitch(record, e, event, 'inLockFlag')}></Switch>
								} else {
									return text
								}

							}
						}
					}) : '';
					let filterArr = arr.filter(function (item) { return item.display === 'Y' });
					this.setState({ columns: filterArr, columnsWidth: res.totalWidth, ChineseEnglishSize: language.language == 'EN' ? res.result.language.EN : res.result.language.CN })
				}
			}
		});
	};

	//页面中英文翻译
	getColumnsTable2 = () => {
		let { language } = this.state;
		let data = {
			params: [{
				compontName: 'BatchInformation',
				type: 'C',
			}]
		}
		$http.post('urlS', this, {
			code: '01040073',
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					let arr = res.result.C && res.result.C.length > 0 ? JSON.parse(JSON.stringify(res.result.C)).map((item, index) => {
						return {
							...item,
							key: index + 1,
							title: <div onDoubleClick={() => {
								this.setState({ parameterCode: 'BatchInformation' }, () => {
									this.columnRef.onOpenModel();
								})
							}}>{language.language == 'EN' ? item.enDescripts : item.title}</div>,
							render: (text, record) => {
								if (item.code === 'ordActive') {
									return <Switch checkedChildren={language.language == 'EN' ? 'YES' : "是"} unCheckedChildren={language.language == 'EN' ? 'NO' : "否"} checked={record.ordActive === 1 ? true : false} onChange={(e) => this.handleChange(record, 'ordActive', e)}></Switch>
								} else if (item.code === 'stkActive') {
									return <Switch checkedChildren={language.language == 'EN' ? 'YES' : "是"} unCheckedChildren={language.language == 'EN' ? 'NO' : "否"} checked={record.stkActive === 1 ? true : false} onChange={(e) => this.handleChange(record, 'stkActive', e)}></Switch>
								} else if (item.code === 'batResQty') {
									return <Tooltip title={language.language == 'EN' ? 'Click on the number of paths to perform related operations' : "点击在途数可进行相关操纵"} placement="topLeft">
										<span className="table-operation">
											<a href="javascript:;" onClick={(e) => this.handleMunuItemOne(record, 'detail', e)}>{record.batResQty}</a>
										</span>
									</Tooltip>
								} else {
									return text
								}

							}
						}
					}) : '';
					let filterArr = arr.filter(function (item) { return item.display === 'Y' });
					this.setState({ detailColumns: filterArr, detailColumnsWidth: res.totalWidth })
				}
			}
		})
	};
	// //页面中英文翻译
	getColumnsTable3 = () => {
		let { language } = this.state;
		let data = {
			params: [{
				compontName: 'InventoryQueryExport',
				type: 'C',
			}]
		}
		$http.post('urlS', this, {
			code: '01040073',
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					let arr = res.result.C && res.result.C.length > 0 ? JSON.parse(JSON.stringify(res.result.C)).map((item, index) => {
						return {
							...item,
							key: index + 1,
							title: <div onDoubleClick={() => {
								this.setState({ parameterCode: 'InventoryQueryExport' }, () => {
									this.columnRef.onOpenModel();
								})
							}}>{language.language == 'EN' ? item.enDescripts : item.title}</div>
						}
					}) : '';
					let filterArr = arr.filter(function (item) { return item.display === 'Y' });
					this.setState({ transitColumns: filterArr, transitColumnsWidth: res.totalWidth })
				}
			}
		})
	};

	componentWillUnmount() {
		// 组件销毁前将静止让setState修改state的状态
		this.setState = (state, callback) => { return; }
	}
	onColumnRef = (ref) => {
		this.columnRef = ref;
	}
	handleMainSwitch = (record, e, event, flag) => {
		event.stopPropagation();
		let obj = record;
		if (flag === 'lockFlag') {
			obj['lockFlag'] = e;
		}
		if (flag === 'outLockFlag') {
			obj['outLockFlag'] = e;
		}
		if (flag === 'inLockFlag') {
			obj['inLockFlag'] = e;
		}
		this.updateMainStatus(obj);
		const newData = [...this.state.mainData];
		const index = newData.findIndex(item => obj.stkLocID === item.stkLocID);
		const item = newData[index];
		newData.splice(index, 1, {
			...item,
			...obj,
		});
		// console.log(newData)
		this.setState({ mainData: newData });
	}

	handleChange = (record, flag, e) => {
		let obj = record;
		obj[flag] = e === true ? 1 : 0;
		// console.log(obj)
		this.updateStatus(obj)
		const newData = [...this.state.detailData];
		const index = newData.findIndex(item => obj.stkLocBatID === item.stkLocBatID);
		const item = newData[index];
		newData.splice(index, 1, {
			...item,
			...obj,
		});
		// console.log(newData)
		this.setState({ detailData: newData });
	}

	// 下拉框数据查询
	getSelectData() {
		let data = {
			params: [{}]
		}
		$http.post('urlS', this, {
			code: "02020073",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					this.setState({ selectData: res.result })
				} else {
					this.setState({ selectData: {} })
				}
			}
		})
	}

	handleMunuItemOne = (record, flag, e) => {
		// console.log(record)
		// 阻止事件冒泡
		e.stopPropagation();
		// console.log(record)
		if (record === this.state.rowDataModal) {
			this.setState({ transitVisible: true, flag })
		} else {
			this.setState({ transitVisible: true, flag, rowDataModal: record }, () => {
				this.getTransitQuery()
			})
		}
	}

	// 调用子组件的连接事件
	onRef = (ref) => {
		this.child = ref
	}

	// 显示分页总条数
	showTotal(total) {
		return `共 ${total} 条`;
	}

	//导出excel
	downloadExl = () => {
		this.setState({ visible: true })
	}

	// 请求列表数据
	getTableData(locID, stockID, endDate, stkCatID, poisonID, busTypeID, formID, onlyUse, onlyNotUse, alias) {
		this.setState({ publicLoading: true });
		let { mainPageSize, mainPage } = this.state;
		let data = {}
		data = {
			params: [{
				locID: locID, // 科室ID
				stockID: stockID, // 药品ID
				endDate: endDate ? Moment(endDate).format('YYYY-MM-DD') : undefined, // 日期
				stkCatID: stkCatID, // 库存大类ID
				poisonID: poisonID, // 管制分类ID
				busTypeID: busTypeID, // 类型
				formID: formID, // 剂型ID
				onlyUse: onlyUse, // 仅在用药品
				onlyNotUse: onlyNotUse, // 仅不可用药品
				alias: alias, //药品别名
			}],
			pagination: [{
				pageSize: mainPageSize,
				currentPage: mainPage,
				sort: "",
				dir: "Asc"
			}]
		}
		$http.post('urlS', this, {
			code: "02020074",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0 && res.result) {
					for (var i = 0; i < res.result.rows.length; i++) {
						res.result.rows[i].key = i
					}
					this.setState({ mainData: res.result.rows, total: res.result.total, publicLoading: false }, () => {
						// 数据加载成功关闭loading
						this.child.handleLoading()
					})
				} else {
					this.setState({ mainData: [], total: 0, publicLoading: false }, () => {
						// 数据加载成功关闭loading
						this.child.handleLoading();
					})
				}
			},
			error: function () {
				this.setState({ mainData: [], total: 0, publicLoading: false }, () => {
					// 数据加载成功关闭loading
					this.child.handleLoading();
				})
			}
		})
	}

	// 查询库存信息
	handleQuery = () => {
		this.setState({ mainPage: 1, mainPageSize: 10, rowId: '', rowData: {}, detailData: [] }, () => {
			let { locID, stockID, endDate, stkCatID, poisonID, busTypeID, formID, onlyUse, onlyNotUse, alias } = this.state;
			this.getTableData(locID, stockID, endDate, stkCatID, poisonID, busTypeID, formID, onlyUse, onlyNotUse, alias);
		})
	}

	// 提供修改page和pageSize的回调函数
	compilePage(page, pageSize) {
		// 修改page，或者pageSize
		this.setState({ mainPage: page, mainPageSize: pageSize }, () => {
			// 重新调用查询方法
			let { locID, stockID, endDate, stkCatID, poisonID, busTypeID, formID, onlyUse, onlyNotUse, alias } = this.state;
			this.getTableData(locID, stockID, endDate, stkCatID, poisonID, busTypeID, formID, onlyUse, onlyNotUse, alias);
		})
	}

	// 请求列表数据
	getDetailTableData() {
		this.setState({ loading: true });
		let { detailPageSize, detailPage, rowData } = this.state;
		let data = {
			params: [{
				stkLocID: rowData.stkLocID, // 科室药品ID
				endDate: rowData.stockID ? Moment(rowData.stockID).format('YYYY-MM-DD') : undefined, // 日期
			}],
			pagination: [{
				pageSize: detailPageSize,
				currentPage: detailPage,
				sort: "",
				dir: "Asc"
			}]
		}
		$http.post('urlS', this, {
			code: "02020075",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0 && res.result) {
					for (var i = 0; i < res.result.rows.length; i++) {
						res.result.rows[i].key = i
					}
					this.setState({ detailData: res.result.rows, detailTotal: res.result.total, loading: false })
				}
			}
		})
	}

	// 查询批次信息
	handleQueryDetail = () => {
		this.setState({ detailPage: 1, detailPageSize: 10 }, () => {
			this.getDetailTableData();
		})
	}

	// 修改分页
	onChange = (page, pageSize) => {
		// 修改page，或者pageSize
		this.setState({ detailPage: page, detailPageSize: this.state.detailPageSize }, () => {
			// 重新调用查询方法
			this.getDetailTableData();
		})
	}

	// 修改条数
	onShowSizeChange = (current, size) => {
		// 修改page，或者pageSize
		this.setState({ detailPage: 1, detailPageSize: size }, () => {
			// 重新调用查询方法
			this.getDetailTableData();
		})
	}

	updateMainStatus(row) {
		let data = {
			params: [
				{
					stkLocID: row.stkLocID,
					lockFlag: row.lockFlag,
					outLockFlag: row.outLockFlag,
					inLockFlag: row.inLockFlag,
				}
			]
		}
		$http.post('urlS', this, {
			code: "02020079",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					message.success(res.errorMessage)
				} else {
					message.error(res.errorMessage)
				}
			}
		})
	}

	updateStatus(row) {
		let data = {
			params: [
				{
					stkLocBatID: row.stkLocBatID,
					ordActive: +row.ordActive === 1 ? true : false,
					stkActive: +row.stkActive === 1 ? true : false
				}
			]
		}
		$http.post('urlS', this, {
			code: "02020076",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					message.success(res.errorMessage)
				} else {
					message.error(res.errorMessage)
				}
			}
		})
	}

	showPrintAllModal = () => {
		let refThis = this;
		Modal.confirm({
			title: "温馨提示",
			centered: true,
			content: "是否确认打印全部药品标签???",
			okText: "继续打印",
			onOk() {
				Modal.destroyAll();
				// 打印
				refThis.printAll()
			},
			cancelText: "取消",
			onCancel() {
				Modal.destroyAll();
			},
		});
	}

	printAll = () => {
		let { locID, stockID, endDate, stkCatID, poisonID, busTypeID, formID, onlyUse, onlyNotUse, alias } = this.state;
		let data = {}
		data = {
			params: [{
				locID: locID, // 科室ID
				stockID: stockID, // 药品ID
				endDate: endDate ? Moment(endDate).format('YYYY-MM-DD') : undefined, // 日期
				stkCatID: stkCatID, // 库存大类ID
				poisonID: poisonID, // 管制分类ID
				busTypeID: busTypeID, // 类型
				formID: formID, // 剂型ID
				onlyUse: onlyUse, // 仅在用药品
				onlyNotUse: onlyNotUse, // 仅不可用药品
				alias: alias, //药品别名
			}],
			pagination: [{
				pageSize: 9999,
				currentPage: 1,
				sort: "",
				dir: "Asc"
			}]
		}
		$http.post('urlS', this, {
			code: "02020074",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0 && res.result) {
					this.child.handleLoading();
					let refThis = this;
					refThis.res = res;
					refThis.$loadTemplate = $loadTemplate;
					Modal.confirm({
						title: "温馨提示",
						centered: true,
						content: "本次打印记录" + refThis.res.result.rows.length + "条，请确认打印机连接是否正确且准备足够的打印纸张！",
						okText: "确认打印",
						onOk() {
							Modal.destroyAll();
							for (var i = 0; i < refThis.res.result.rows.length; i++) {
								let stockDesc = refThis.res.result.rows[i].stockDesc;
								let stockSpec = refThis.res.result.rows[i].stockSpec;
								let printStr = "";
								printStr = 'LODOP.SET_PRINT_STYLEA("stockDesc","CONTENT","' + stockDesc + '");';
								printStr = printStr + 'LODOP.SET_PRINT_STYLEA("spec","CONTENT","' + stockSpec + '");';
								printStr = printStr + 'LODOP.PRINT();';
								refThis.$loadTemplate("DrugLabel", printStr);
							}
						},
						cancelText: "取消",
						onCancel() {
							Modal.destroyAll();
						},
					});

				} else {
					this.child.handleLoading();
				}
			},
			error: function () {
				this.child.handleLoading();
			}
		})
	}

	printOne = () => {
		let stockDesc = this.state.rowData.stockDesc;
		if (stockDesc == '') {
			message.warn("请选择记录后再打印!");
		}
		let stockSpec = this.state.rowData.stockSpec;
		let printStr = "";
		printStr = 'LODOP.SET_PRINT_STYLEA("stockDesc","CONTENT","' + stockDesc + '");';
		printStr = printStr + 'LODOP.SET_PRINT_STYLEA("spec","CONTENT","' + stockSpec + '");';
		printStr = printStr + 'LODOP.PRINT();';
		console.log(printStr);
		$loadTemplate("DrugLabel", printStr);
	}

	// 操作行
	onClickRowPublic = (record) => {
		return {
			// 单击行选中
			onClick: () => {
				if (this.state.rowId === '') {
					// 保存行数据以及ID
					this.setState({ rowId: record.key, rowData: record, printOneStatus: false }, () => {
						this.getDetailTableData()
					})
				} else {
					if (this.state.rowId !== record.key) {
						this.setState({ rowId: record.key, rowData: record, printOneStatus: false }, () => {
							this.getDetailTableData()
						})
					} else {
						this.setState({ rowId: '', rowData: {}, detailData: [], printOneStatus: true })
					}
				}
			}
		}
	}

	// 选中行操作
	setRowClassNamePublic = (record) => {
		return record.key === this.state.rowId ? 'clickRowStyle' : '';
	}

	// 关闭弹窗
	onCancel = () => {
		this.setState({ visible: false })
	}

	// 导出库存信息表
	exportInventoryInformation() {
		let { locID, stockID, endDate, stkCatID, poisonID, busTypeID, formID, onlyUse, onlyNotUse, ChineseEnglishSize, language } = this.state;
		let data = {}
		data = {
			params: [{
				locID: locID, // 科室ID
				stockID: stockID, // 药品ID
				endDate: endDate ? Moment(endDate).format('YYYY-MM-DD') : undefined, // 日期
				stkCatID: stkCatID, // 库存大类ID
				poisonID: poisonID, // 管制分类ID
				busTypeID: busTypeID, // 类型
				formID: formID, // 剂型ID
				onlyUse: onlyUse, // 仅在用药品
				onlyNotUse: onlyNotUse, // 仅不可用药品
			}],
			pagination: [{
				pageSize: 10000,
				currentPage: 1,
				sort: "",
				dir: "Asc"
			}]
		}
		$http.post('urlS', this, {
			code: "02020074",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0 && res.result) {
					let arr = res.result.rows ? res.result.rows : [];
					for (var i = 0; i < arr.length; i++) {
						arr[i].key = i
						if (arr[i].lockFlag === true) {
							arr[i].lockFlag = language.language == 'EN' ? 'YES' : '是'
						} else {
							arr[i].lockFlag = language.language == 'EN' ? 'NO' : '否'
						}
					}
					handleExcel.exportExcel(this.columns, arr, ChineseEnglishSize.InventoryInquiryinventoryInfoTable ? ChineseEnglishSize.InventoryInquiryinventoryInfoTable.descripts : '库存信息表')
					message.success(ChineseEnglishSize.InventoryInquiryexInventoryTableSuc ? ChineseEnglishSize.InventoryInquiryexInventoryTableSuc.descripts : "导出库存信息表成功");
					this.setState({ visible: false });
				}
			}
		})
	}

	// 导出批次信息表
	exportBatchInformation() {
		let { rowData, ChineseEnglishSize, language } = this.state;
		let data = {
			params: [{
				stkLocID: rowData.stkLocID, // 科室药品ID
				endDate: rowData.stockID ? Moment(rowData.stockID).format('YYYY-MM-DD') : undefined, // 日期
			}],
			pagination: [{
				pageSize: 10000,
				currentPage: 1,
				sort: "",
				dir: "Asc"
			}]
		}
		$http.post('urlS', this, {
			code: "02020075",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0 && res.result) {
					let arr = res.result.rows ? res.result.rows : [];
					for (var i = 0; i < arr.length; i++) {
						if (+arr[i].stkActive === 1) {
							arr[i].stkActive = language.language == 'EN' ? 'YES' : '是'
						} else {
							arr[i].stkActive = language.language == 'EN' ? 'NO' : '否'
						}
						if (+arr[i].ordActive === 1) {
							arr[i].ordActive = language.language == 'EN' ? 'YES' : '是'
						} else {
							arr[i].ordActive = language.language == 'EN' ? 'NO' : '否'
						}
					}
					handleExcel.exportExcel(this.detailColumns, arr, ChineseEnglishSize.InventoryInquirybatchInfoTable ? ChineseEnglishSize.InventoryInquirybatchInfoTable.descripts : '批次信息表');
					message.success(ChineseEnglishSize.InventoryInquiryexbatchTableSuc ? ChineseEnglishSize.InventoryInquiryexbatchTableSuc.descripts : "导出批次信息表成功");
					this.setState({ visible: false });
				}
			}
		})
	}

	// 确定
	onOk = () => {
		let { checkMainValue, checkDetailValue, ChineseEnglishSize } = this.state;
		if (checkMainValue && checkDetailValue) {// 同时导出两张表
			this.exportInventoryInformation()
			this.exportBatchInformation()
		} else if (checkMainValue) {// 导出库存信息表
			let { mainPageSize, mainPage, locID, stockID, endDate, stkCatID, poisonID, busTypeID, formID, onlyUse, onlyNotUse, alias } = this.state;
			let data = {
				params: [{
					locID: locID, // 科室ID
					stockID: stockID, // 药品ID
					endDate: endDate ? Moment(endDate).format('YYYY-MM-DD') : undefined, // 日期
					stkCatID: stkCatID, // 库存大类ID
					poisonID: poisonID, // 管制分类ID
					busTypeID: busTypeID, // 类型
					formID: formID, // 剂型ID
					onlyUse: onlyUse, // 仅在用药品
					onlyNotUse: onlyNotUse, // 仅不可用药品
					alias: alias, //药品别名
				}],
				pagination: [{
					pageSize: 10000,
					currentPage: 1,
					sort: "",
					dir: "Asc"
				}]
			}
			$http.post('urlS', this, {
				code: "02020338",
				data: data,
				success: function (res) {
					if (+res.errorCode === 0 && res.result && res.result.filePath) {
						document.getElementById("iframe").src = window.location.protocol + "//" + window.location.host + res.result.filePath;

						setTimeout(() => {
							this.onCancel();
						}, 100)
					}
				}
			})
			// this.exportInventoryInformation()
		} else if (checkDetailValue) {
			// 导出批次信息表
			let { locID, stockID, endDate, stkCatID, poisonID, busTypeID, formID, onlyUse, onlyNotUse, alias } = this.state;
			let data = {
				params: [{
					locID: locID, // 科室ID
					stockID: stockID, // 药品ID
					endDate: endDate ? Moment(endDate).format('YYYY-MM-DD') : undefined, // 日期
					stkCatID: stkCatID, // 库存大类ID
					poisonID: poisonID, // 管制分类ID
					busTypeID: busTypeID, // 类型
					formID: formID, // 剂型ID
					onlyUse: onlyUse, // 仅在用药品
					onlyNotUse: onlyNotUse, // 仅不可用药品
					alias: alias, //药品别名
				}],
				pagination: [{
					pageSize: 10000,
					currentPage: 1,
					sort: "",
					dir: "Asc"
				}]
			}
			$http.post('urlS', this, {
				code: "02020302",
				data: data,
				success: function (res) {
					if (+res.errorCode === 0 && res.result && res.result.filePath) {
						document.getElementById("iframe").src = window.location.protocol + "//" + window.location.host + res.result.filePath;
						setTimeout(() => {
							this.onCancel();
						}, 100)
					}
				}
			})
			// this.exportBatchInformation()
		} else {
			message.info(ChineseEnglishSize.InventoryInquiryselectExportData ? ChineseEnglishSize.InventoryInquiryselectExportData.descripts : "请选择需要导出的表格")
		}
	}

	// 操作库存信息Checkbox
	checkedMain = (e) => {
		this.setState({ checkMainValue: e.target.checked })
	}

	// 操作批次信息Checkbox
	checkedDetails = (e) => {
		this.setState({ checkDetailValue: e.target.checked })
	}

	// 查询条件 --- 科室
	onChangelocID = (e) => {
		this.setState({ locID: e });
	}

	// 查询条件 --- 日期
	onChangeDate = (e) => {
		this.setState({ endDate: e }, () => {
			this.handleOnSelect(2)
		});
	}

	// 查询条件 --- 类型
	onChangebusTypeID = (e) => {
		this.setState({ busTypeID: e });
	}

	// 查询条件 --- 药品名称
	onChangestockID = (e) => {
		this.setState({
			stockID: e.target.value
		});
	}

	// 查询条件 --- 药品别名
	onChangealias = (e) => {
		this.setState({
			alias: e.target.value
		});
	}

	// 查询条件 --- 库存大类
	onChangestkCatID = (e) => {
		this.setState({ stkCatID: e });
	}

	// 查询条件 --- 管制分类
	onChangepoisonID = (e) => {
		this.setState({ poisonID: e });
	}

	// 查询条件 --- 剂型
	onChangeformID = (e) => {
		this.setState({ formID: e });
	}

	// 查询条件 --- 仅在用药品
	onChangeOnlyUse = (e) => {
		this.setState({ onlyUse: e }, () => {
			this.handleOnSelect(8)
		});
	}

	// 查询条件 --- 仅不可用药品
	onChangeOnlyNotUse = (e) => {
		this.setState({ onlyNotUse: e }, () => {
			this.handleOnSelect(9)
		});
	}

	// 开单科室
	handleTransitOnChange = (e) => {
		this.setState({ transitValue: e });
	}

	// 重置
	resetFields = () => {
		this.setState({
			locID: user && user.locID ? user.locID : undefined, // 科室
			stockID: undefined, // 药品
			endDate: undefined, // 日期
			stkCatID: undefined, // 库存分类
			poisonID: undefined, // 管制分类
			busTypeID: undefined, // 类型
			formID: undefined, // 剂型
			onlyUse: undefined, // 仅在用药品
			onlyNotUse: undefined, // 仅不可用药品
			alias: undefined, //药品别名
		})
	}

	// 下拉框选中事件
	handleOnSelect = (num) => {
		switch (num) {
			case 1:
				setTimeout(() => {
					this.myRef2.current.focus();
				}, 300)
				break;
			case 2:
				setTimeout(() => {
					this.myRef3.current.focus();
				}, 300)
				break;
			case 3:
				setTimeout(() => {
					this.myRef4.current.focus();
				}, 300)
				break;
			case 4:
				this.handleQuery();
				setTimeout(() => {
					// this.myRef5.current.focus();  //别名回车焦点不变
				}, 300)
				break;
			case 5:
				setTimeout(() => {
					this.myRef6.current.focus();
				}, 300)
				break;
			case 6:
				setTimeout(() => {
					this.myRef7.current.focus();
				}, 300)
				break;
			case 7:
				setTimeout(() => {
					this.myRef8.current.focus();
				}, 300)
				break;
			case 8:
				setTimeout(() => {
					this.myRef9.current.focus();
				}, 300)
				break;
			default:
				setTimeout(() => {
					this.myRef1.current.focus();
				}, 300)
		}
	}

	// 关闭在途数窗口
	transitOnCancel = () => {
		this.setState({ transitVisible: false })
	}

	// 选择行数据 -- 在途数弹窗
	transitOnClickRow = (record) => {
		return {
			onClick: () => {
				let { transitSelectedRowKeys, transitRowData } = this.state;
				let findFlag = false;
				let start = 0;
				if (transitSelectedRowKeys) {
					transitSelectedRowKeys.find(function (value, key) {
						if (value === record.key) {
							//遍历找到选中的数据，并记录下选中数据在数组中的key
							findFlag = true;
							start = key;
						}
					})
				}
				if (findFlag) {
					//再次点击移除选中
					transitSelectedRowKeys.splice(start, 1);
					transitRowData.splice(start, 1);
				} else {
					//将点击的行添加到选中
					transitSelectedRowKeys.push(record.key);
					transitRowData.push(record);
				}
				if (this.state.transitRowId === "") {
					this.setState({
						transitRowId: record.key,
						transitSelectedRowKeys,
						transitRowData
					});
				} else {
					if (this.state.transitRowId !== record.key) {
						this.setState({
							transitRowId: record.key,
							transitSelectedRowKeys,
							transitRowData
						});
					} else {
						this.setState({
							transitRowId: "",
							transitSelectedRowKeys,
							transitRowData
						});
					}
				}
			}
		}
	}

	// 选中行class名 -- 在途数弹窗
	transitSetRowClassName = (record) => {
		return (("^" + this.state.transitSelectedRowKeys.join("^") + "^").indexOf("^" + record.key + "^") > -1) ? 'clickRowStyle' : '';
	}

	// 3.1.2.2.1.开单科室下拉框数据集
	getTransitSelectData = () => {
		let data = {
			params: []
		}
		$http.post('urlS', this, {
			code: "02020119",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					this.setState({ transitSelectData: res.result })
				}
			}
		})
	}

	// 请求列表数据
	getTransitTableData(transitValue) {
		this.setState({ detailsLoading: true })
		let { rowDataModal, transitPageSize, transitPage } = this.state;
		let data = {
			params: [{
				stkLocID: this.state.flag === 'main' ? rowDataModal.stkLocID : undefined, // 科室库存项ID
				ordLocID: transitValue, // 开单科室ID
				stkLocBatID: this.state.flag === 'detail' ? rowDataModal.stkLocBatID : undefined
			}],
			pagination: [{
				pageSize: transitPageSize,
				currentPage: transitPage,
				sort: "",
				dir: "Asc"
			}]
		}
		$http.post('urlS', this, {
			code: "02020120",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					let arr = res.result[0] && res.result[0].rows ? res.result[0].rows : [];
					for (var i = 0; i < arr.length; i++) {
						arr[i].key = i + 1
					}
					this.setState({ transitTableData: arr, transitTotal: res.result[0] && res.result[0].total, transitSelectedRowKeys: [], transitRowId: "", transitRowData: [], detailsLoading: false })
				} else {
					this.setState({ transitTableData: [], transitTotal: 0, transitSelectedRowKeys: [], transitRowData: [], transitRowId: "" })
				}
			}
		})
	}

	// 3.1.2.2.2.获取在途数明细
	getTransitQuery = () => {
		this.setState({ transitPage: 1, transitPageSize: 10 }, () => {
			let { transitValue } = this.state;
			this.getTransitTableData(transitValue);
		})
	}

	handleTransitPagination = (page, pageSize) => {
		this.setState({ transitPage: page, transitPageSize: this.state.transitPageSize }, () => {
			let { transitValue } = this.state;
			this.getTransitTableData(transitValue)
		})
	}

	handleTransitOnShowSizeChange = (page, pageSize) => {
		this.setState({ transitPage: 1, transitPageSize: pageSize }, () => {
			let { transitValue } = this.state;
			this.getTransitTableData(transitValue)
		})
	}

	// 清除
	transitOnOk = () => {
		let { ChineseEnglishSize } = this.state;
		let arr = this.state.transitRowData && JSON.parse(JSON.stringify(this.state.transitRowData)).map(item => {
			return {
				reswayID: item.reswayID
			}
		})
		let data = {
			params: arr
		}
		$http.post('urlS', this, {
			code: "02020121",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					message.success(ChineseEnglishSize.InventoryInquiryclearSucc ? ChineseEnglishSize.InventoryInquiryclearSucc.descripts : "清除成功");
					this.setState({ transitSelectedRowKeys: [], transitRowData: [], transitRowId: '' }, () => {
						this.handleQuery();
						this.transitOnCancel();
					})
				}
			}
		})
	}

	render() {
		let { detailColumns, ChineseEnglishSize, columns, transitColumns, language } = this.state;
		// 组件所需参数
		const param = {
			// 表头配置
			columns: columns.length > 0 ? columns : this.columns,
			// 表格数据
			data: this.state.mainData,
			// 数据总条数
			total: this.state.total,
			// 当前页数
			page: this.state.mainPage,
			// 表格的宽度
			x: this.state.columnsWidth,
			y: store.getState().tableHeight.y / 2 - 28,
			height: store.getState().tableHeight.y / 2 + 17 + 'px',
			isOnRow: true,
			rowClassName: true,
			loading: this.state.publicLoading
		}
		// 科室
		let departmentOption = this.state.selectData.loc && this.state.selectData.loc.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})
		// 类型
		let typeOption = this.state.selectData.busType && this.state.selectData.busType.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})
		// 库存大类
		let stkCatOption = this.state.selectData.stkCat && this.state.selectData.stkCat.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})
		// 管制分类
		let poisonOption = this.state.selectData.poison && this.state.selectData.poison.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} titseatchprople={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})
		// 剂型
		let formOption = this.state.selectData.form && this.state.selectData.form.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})

		// 开单科室
		let transitOption = this.state.transitSelectData && this.state.transitSelectData.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})

		const rowSelection = {
			selectedRowKeys: this.state.transitSelectedRowKeys,
			selectedRows: this.state.transitRowData,
			onChange: (selectedRowKeys, selectedRows) => {
				// console.log(selectedRowKeys, selectedRows)
				let rowId = "";
				if (selectedRowKeys.length !== 0) {
					rowId = selectedRowKeys[selectedRowKeys.length - 1];
				}
				this.setState({ transitSelectedRowKeys: selectedRowKeys, transitRowData: selectedRows, transitRowId: rowId })
			}
		};

		return (
			<div className="stock-search">
				<Row>
					<Col xs={12} sm={12} md={10} lg={8} xl={6} xxl={4}>
						<Card
							size="small"
							title={<div className="card-title-left-icon"><div></div>{ChineseEnglishSize.InventoryInquirybuttonOperation ? ChineseEnglishSize.InventoryInquirybuttonOperation.descripts : '按钮操作'}</div>}
							className="card-body-padding"
						>
							<div style={{ textAlign: 'center' }}>
								<Button type="primary" onClick={this.handleQuery} style={{ marginTop: '12px' }}>{ChineseEnglishSize.InventoryInquirysearch ? ChineseEnglishSize.InventoryInquirysearch.descripts : '查询'}</Button>
								<Button style={{ margin: '0 8px' }} onClick={this.resetFields}>{ChineseEnglishSize.InventoryInquiryReset ? ChineseEnglishSize.InventoryInquiryReset.descripts : '重置'}</Button>
								<Button onClick={this.downloadExl} type="dashed" style={{ margin: '12px 0' }}>
									<Icon type="export" />{ChineseEnglishSize.InventoryInquiryexport ? ChineseEnglishSize.InventoryInquiryexport.descripts : '导出'}
								</Button>
							</div>
						</Card>
						<div style={{ height: '6px', background: 'rgba(240, 242, 245, 1)', width: '100%' }}></div>
						<Card
							size="small"
							title={<div className="card-title-left-icon"><div></div>{ChineseEnglishSize.InventoryInquirySearchTitle ? ChineseEnglishSize.InventoryInquirySearchTitle.descripts : '查询条件'}</div>}
							style={{ borderBottom: 0 }}
						>
							<div>
								<Row style={{ marginBottom: '12px' }}>
									<Col span={8} style={{ textAlign: 'right' }}>
										{ChineseEnglishSize.InventoryInquiryloc ? ChineseEnglishSize.InventoryInquiryloc.descripts : '科室：'}
									</Col>
									<Col span={16}>
										<Select showSearch optionFilterProp="seatchprop" placeholder={ChineseEnglishSize.InventoryInquirypleaseChoose ? ChineseEnglishSize.InventoryInquirypleaseChoose.descripts : '请选择'} style={{ width: '150px' }} value={this.state.locID} onChange={this.onChangelocID} ref={this.myRef1} onSelect={() => this.handleOnSelect(1)}>
											{departmentOption}
										</Select>
									</Col>
								</Row>
								<Row style={{ marginBottom: '12px' }}>
									<Col span={8} style={{ textAlign: 'right' }}>
										{ChineseEnglishSize.InventoryInquirydate ? ChineseEnglishSize.InventoryInquirydate.descripts : '日期：'}
									</Col>
									<Col span={16}>
										<DatePicker placeholder={ChineseEnglishSize.InventoryInquirypleaseChoose ? ChineseEnglishSize.InventoryInquirypleaseChoose.descripts : '请选择'} style={{ width: '150px' }} value={this.state.endDate} onChange={this.onChangeDate} ref={this.myRef2} />
									</Col>
								</Row>
								<Row style={{ marginBottom: '12px' }}>
									<Col span={8} style={{ textAlign: 'right' }}>
										{ChineseEnglishSize.InventoryInquirytype ? ChineseEnglishSize.InventoryInquirytype.descripts : '类型：'}
									</Col>
									<Col span={16}>
										<Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.InventoryInquirypleaseChoose ? ChineseEnglishSize.InventoryInquirypleaseChoose.descripts : '请选择'} style={{ width: '150px' }} value={this.state.busTypeID} onChange={this.onChangebusTypeID} ref={this.myRef3} onSelect={() => this.handleOnSelect(3)}>
											{typeOption}
										</Select>
									</Col>
								</Row>
								<Row style={{ marginBottom: '12px' }}>
									<Col span={8} style={{ textAlign: 'right' }}>
										{ChineseEnglishSize.InventoryInquirydrugAlias ? ChineseEnglishSize.InventoryInquirydrugAlias.descripts : '药品别名：'}
									</Col>
									<Col span={16}>
										<Input allowClear placeholder="请输入" style={{ width: '150px' }} value={this.state.alias} onChange={this.onChangealias} ref={this.myRef4} onPressEnter={() => this.handleOnSelect(4)} />
									</Col>
								</Row>
								<Row style={{ marginBottom: '12px' }}>
									<Col span={8} style={{ textAlign: 'right' }}>
										{ChineseEnglishSize.InventoryInquirystkCatID ? ChineseEnglishSize.InventoryInquirystkCatID.descripts : '库存大类：'}
									</Col>
									<Col span={16}>
										<Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.InventoryInquirypleaseChoose ? ChineseEnglishSize.InventoryInquirypleaseChoose.descripts : '请选择'} style={{ width: '150px' }} value={this.state.stkCatID} onChange={this.onChangestkCatID} ref={this.myRef5} onSelect={() => this.handleOnSelect(5)}>
											{stkCatOption}
										</Select>
									</Col>
								</Row>
								<Row style={{ marginBottom: '12px' }}>
									<Col span={8} style={{ textAlign: 'right' }}>
										{ChineseEnglishSize.InventoryInquirypoisonID ? ChineseEnglishSize.InventoryInquirypoisonID.descripts : '管制分类：'}
									</Col>
									<Col span={16}>
										<Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.InventoryInquirypleaseChoose ? ChineseEnglishSize.InventoryInquirypleaseChoose.descripts : '请选择'} style={{ width: '150px' }} value={this.state.poisonID} onChange={this.onChangepoisonID} ref={this.myRef6} onSelect={() => this.handleOnSelect(6)}>
											{poisonOption}
										</Select>
									</Col>
								</Row>
								<Row style={{ marginBottom: '12px' }}>
									<Col span={8} style={{ textAlign: 'right' }}>
										{ChineseEnglishSize.InventoryInquiryformID ? ChineseEnglishSize.InventoryInquiryformID.descripts : '剂型：'}
									</Col>
									<Col span={16}>
										<Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.InventoryInquirypleaseChoose ? ChineseEnglishSize.InventoryInquirypleaseChoose.descripts : '请选择'} style={{ width: '150px' }} value={this.state.formID} onChange={this.onChangeformID} ref={this.myRef7} onSelect={() => this.handleOnSelect(7)}>
											{formOption}
										</Select>
									</Col>
								</Row>
								<Row style={{ marginBottom: '12px' }}>
									<Col span={12} style={{ textAlign: 'right' }}>
										{ChineseEnglishSize.InventoryInquiryinUseDrug ? ChineseEnglishSize.InventoryInquiryinUseDrug.descripts : '仅在用药品：'}
									</Col>
									<Col span={12}>
										{language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" checked={this.state.onlyUse} onChange={this.onChangeOnlyUse} ref={this.myRef8} /> : <Switch checkedChildren="是" unCheckedChildren="否" checked={this.state.onlyUse} onChange={this.onChangeOnlyUse} ref={this.myRef8} />}
									</Col>
								</Row>
								<Row style={{ marginBottom: '12px' }}>
									<Col span={12} style={{ textAlign: 'right' }}>
										{ChineseEnglishSize.InventoryInquiryunavailableDrug ? ChineseEnglishSize.InventoryInquiryunavailableDrug.descripts : '仅不可用药品：'}
									</Col>
									<Col span={12}>
										{language.language == 'EN' ? <Switch checkedChildren="Yes" unCheckedChildren="No" checked={this.state.onlyNotUse} onChange={this.onChangeOnlyNotUse} ref={this.myRef9} /> : <Switch checkedChildren="是" unCheckedChildren="否" checked={this.state.onlyNotUse} onChange={this.onChangeOnlyNotUse} ref={this.myRef9} />}
									</Col>
								</Row>
							</div>
						</Card>
					</Col>
					<Col xs={12} sm={12} md={14} lg={16} xl={18} xxl={20}>
						<div style={{ paddingLeft: '6px', position: 'relative' }}>
							<Card
								size="small"
								title={<div className="card-title-left-icon"><div></div>{ChineseEnglishSize.InventoryInquiryinventoryInfo ? ChineseEnglishSize.InventoryInquiryinventoryInfo.descripts : '库存信息'}</div>}
								extra={<div><Button onClick={this.printOne} type="dashed" size="small" disabled={this.state.printOneStatus}><Icon type="printer" />打印当前标签</Button><Button onClick={this.showPrintAllModal} type="dashed" size="small" style={{ marginLeft: "15px" }}><Icon type="printer" />一键打印全部标签</Button></div>}
							>
								<PubilcTablePagination param={param} handelThis={this} onRef={this.onRef} onClickRowPublic={this.onClickRowPublic} setRowClassNamePublic={this.setRowClassNamePublic} />
							</Card>
							<div style={{ height: '6px', background: 'rgba(240, 242, 245, 1)', width: '100%' }}></div>
							<Card
								size="small"
								title={<div className="card-title-left-icon"><div></div>{ChineseEnglishSize.InventoryInquirybatchInfo ? ChineseEnglishSize.InventoryInquirybatchInfo.descripts : '批次信息'}</div>}

							>
								<div className="batch-information">
									<Table
										style={{ height: store.getState().tableHeight.y / 2 + 15 + 'px' }}
										columns={detailColumns.length > 0 ? detailColumns : this.detailColumns}
										dataSource={this.state.detailData}
										pagination={false}
										bordered
										scroll={{ x: this.state.detailColumnsWidth, y: store.getState().tableHeight.y / 2 - 30 }}
									/>
									<CommonPagination size='small' current={this.state.detailPage} total={this.state.detailTotal} search='search'
										onShowSizeChange={this.onShowSizeChange.bind(this)} complete={true} dataSource={this.state.detailData}
										loading={this.state.loading} onChange={this.onChange.bind(this)} />
								</div>
							</Card>
							<div style={{ width: '6px', background: 'rgba(240, 242, 245, 1)', position: 'absolute', top: 0, left: 0, height: '100%' }}></div>
						</div>
					</Col>
				</Row>
				<Modal
					visible={this.state.visible}
					title={<div>导出Excel表格<span style={{ opacity: '0.5', fontSize: "12px", marginLeft: "8px" }}>({ChineseEnglishSize.InventoryInquiryexportTips ? ChineseEnglishSize.InventoryInquiryexportTips.descripts : '提示：当表格存在数据时才支持导出功能。'})</span></div>}
					okText="确定"
					onCancel={this.onCancel}
					onOk={this.onOk}
				>
					<Row style={{ textAlign: 'center', margin: '12px 0' }}>
						<Col>
							<Col span={12}>
								{ChineseEnglishSize.InventoryInquiryexInventoryTable ? ChineseEnglishSize.InventoryInquiryexInventoryTable.descripts : '导出库存信息表：'}<Checkbox checked={this.state.checkMainValue} onChange={this.checkedMain} disabled={this.state.mainData.length < 1} />
							</Col>
							<Col span={12}>
								{ChineseEnglishSize.InventoryInquiryexbatchTable ? ChineseEnglishSize.InventoryInquiryexbatchTable.descripts : '导出批次信息表：'}<Checkbox checked={this.state.checkDetailValue} onChange={this.checkedDetails} disabled={this.state.mainData.length < 1} />
							</Col>
						</Col>
					</Row>
					<iframe id="iframe" style={{ display: 'none' }}></iframe>
				</Modal>
				<Modal
					visible={this.state.transitVisible}
					title={ChineseEnglishSize.InventoryInquirytransitDetail ? ChineseEnglishSize.InventoryInquirytransitDetail.descripts : '在途数明细'}
					okText={ChineseEnglishSize.InventoryInquiryremove ? ChineseEnglishSize.InventoryInquiryremove.descripts : '清除'}
					onCancel={this.transitOnCancel}
					onOk={this.transitOnOk}
					width={900}
				>
					<div style={{ minHeight: '480px' }}>
						<Row style={{ marginBottom: '15px' }}>
							{ChineseEnglishSize.InventoryInquirydeptOfMakePreForm ? ChineseEnglishSize.InventoryInquirydeptOfMakePreForm.descripts : '开单科室：'}<Select value={this.state.transitValue} onChange={this.handleTransitOnChange} showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.InventoryInquirypleaseChoose ? ChineseEnglishSize.InventoryInquirypleaseChoose.descripts : '请选择'} style={{ width: '150px' }}>
								{transitOption}
							</Select>
							<Button style={{ marginLeft: '15px' }} onClick={this.getTransitQuery}>{ChineseEnglishSize.InventoryInquirysearch ? ChineseEnglishSize.InventoryInquirysearch.descripts : '查询'}</Button>
						</Row>
						<div className="transit-table">
							<Table
								bordered
								rowSelection={rowSelection}
								columns={transitColumns.length > 0 ? transitColumns : this.transitColumns}
								dataSource={this.state.transitTableData}
								pagination={false}
								onRow={this.transitOnClickRow}
								rowClassName={this.transitSetRowClassName}
								style={{ height: '400px' }}
								scroll={{ x: 1460, y: 350 }}
								className="clearBackground"
							/>
							<CommonPagination size='small' current={this.state.transitPage} total={this.state.transitTotal} search='search'
								onShowSizeChange={this.handleTransitOnShowSizeChange.bind(this)} complete={true} dataSource={this.state.transitTableData}
								loading={this.state.detailsLoading} onChange={this.handleTransitPagination.bind(this)} />
						</div>
					</div>
				</Modal>
				<ColumnAuthoritysModel
					clientWidth='800px'
					compontName={this.state.parameterCode}
					configType="C"
					onRef={this.onColumnRef}
					reloadData={() => {
						if (this.state.parameterCode == 'InventoryInfo') {
							this.getColumnsTable1()
						} else if (this.state.parameterCode == 'BatchInformation') {
							this.getColumnsTable2()
						} else if (this.state.parameterCode == 'InventoryQueryExport') {
							this.getColumnsTable3()
						}
					}
					}
				/>
			</div>
		)
	}
};